home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Performance Co-Pilot 1.3
/
SGI Performance Co-Pilot 1.3.iso
/
dist
/
pcp.idb
/
usr
/
share
/
catman
/
u_man
/
cat1
/
pmgenmap.z
/
pmgenmap
Wrap
Text File
|
1997-04-03
|
8KB
|
265 lines
PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111)))) PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))
NNNNAAAAMMMMEEEE
ppppmmmmggggeeeennnnmmmmaaaapppp - generate C code to simplify handling of performance metrics
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
ppppmmmmggggeeeennnnmmmmaaaapppp [_i_n_f_i_l_e]
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
Given one or more lists of metric names in _i_n_f_i_l_e or on standard input,
ppppmmmmggggeeeennnnmmmmaaaapppp generates C declarations and ccccpppppppp(1) macros suitable for use
acrosss the Performance Metrics Programming Interface (PMAPI) on standard
output.
The declarations produced by ppppmmmmggggeeeennnnmmmmaaaapppp simplify the coding for client
applications using the PMAPI.
The input should consist of one or more lists of metric names of the form
listname {
metricname1 symbolname1
metricname2 symbolname2
...
}
which will generate C and ccccpppppppp(1) declarations of the form
char *listname[] = {
#define symbolname1 0
"metricname1",
#define symbolname2 1
"metricname2",
...
};
The array declarations produced are suitable as parameters to
ppppmmmmLLLLooooooookkkkuuuuppppNNNNaaaammmmeeee(3) and the ####ddddeeeeffffiiiinnnneeeed constants may be used to index the _v_s_e_ts
in the _p_m_R_e_s_u_l_t structure returned by a ppppmmmmFFFFeeeettttcccchhhh(3) call.
Obviously, _l_i_s_t_n_a_m_e must conform to the C identifier naming rules, each
_s_y_m_b_o_l_n_a_m_e must confrom to the ccccpppppppp(1) macro naming rules, and each
_m_e_t_r_i_c_n_a_m_e is expected to be a valid performance metrics name (see
ppppmmmmnnnnssss(4) for more details).
The input may include sssshhhh-style comment lines, i.e. with a `####' as the
first non-blank character of a line, and these are translated on output
to either single line or multi-line C comments in the K&R style. For
example, the input:
# leading block of multi-line comments
# RCS: $Revision: 2.3 $
# initialization group
foo {
PPPPaaaaggggeeee 1111
PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111)))) PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))
a.b.c ONE
d.e.f.g TWO
# embedded block of multi-lines
# comments and boring pad text
xx.yy.zz THREE
}
# trailing single line comment
Produces the output:
/*
* leading block of multi-line comments
* RCS: $Revision: 2.3 $
* initialization group
*/
char *foo[] = {
#define ONE 0
"a.b.c",
#define TWO 1
"d.e.f.g",
/*
* embedded block of multi-lines
* comments and boring pad text
*/
#define THREE 2
"xx.yy.zz",
};
/* trailing single line comment */
EEEEXXXXAAAAMMMMPPPPLLLLEEEE
For brevity we have removed the error handling code, and assumed the
chosen metrics do not have multiple values.
The input file
mystats {
irix.kernel.percpu.cpu.idle IDLE
irix.kernel.percpu.cpu.sys SYS
irix.kernel.percpu.cpu.user USER
hinv.ncpu NCPU
}
produces the following C code, suitable for ####iiiinnnncccclllluuuuddddeeee-ing
/*
* Performance Metrics Name Space Map
* Built by pmgenmap from the file
* mystats.metrics
PPPPaaaaggggeeee 2222
PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111)))) PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))
* on Wed Dec 28 19:44:17 EST 1994
*
* Do not edit this file!
*/
char *mystats[] = {
#define IDLE 0
"irix.kernel.percpu.cpu.idle",
#define SYS 1
"irix.kernel.percpu.cpu.sys",
#define USER 2
"irix.kernel.percpu.cpu.user",
#define NCPU 3
"hinv.ncpu",
};
Using the code generated by ppppmmmmggggeeeennnnmmmmaaaapppp, we are now able to easily obtain
metrics from the Performance Metrics Collection Subsystem (PMCS) as
follows:
#define MAX_PMID 4
int trip = 0;
int numpmid = sizeof(mystats)/sizeof(mystats[0]);
double duration;
pmResult *resp;
pmResult *prev;
pmID pmidlist[MAX_PMID];
pmLoadNameSpace(PM_NS_DEFAULT);
pmLookupName(numpmid, mystats, pmidlist);
pmFetch(numpmid, pmidlist, &resp);
printf("%d CPUs: %d usr %d sys %d idle0,
resp->vset[NCPU]->vlist[0].value.lval,
resp->vset[USER]->vlist[0].value.lval,
resp->vset[SYS]->vlist[0].value.lval,
resp->vset[IDLE]->vlist[0].value.lval);
Some calls to ensure portability have been removed from the code above
for the sake of clarity - the example above should not be used as a
template for programming. In particular, the raw values of the metrics
were used when ppppmmmmLLLLooooooookkkkuuuuppppDDDDeeeesssscccc(3) should have been called to determine the
semantics of each metric.
More complete examples that demonstrate the use of ppppmmmmggggeeeennnnmmmmaaaapppp and may be
used as a basis for program development are included in the PCP demos,
e.g. /_v_a_r/_p_c_p/_d_e_m_o_s/_p_m_c_l_i_e_n_t.
PPPPaaaaggggeeee 3333
PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111)))) PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))
FFFFIIIILLLLEEEESSSS
////vvvvaaaarrrr////ppppccccpppp////ppppmmmmnnnnssss////* default PMNS specification files
SSSSEEEEEEEE AAAALLLLSSSSOOOO
ccccpppppppp(1), PPPPMMMMAAAAPPPPIIII(3), ppppmmmmFFFFeeeettttcccchhhh(3), ppppmmmmLLLLooooaaaaddddNNNNaaaammmmeeeeSSSSppppaaaacccceeee(3), ppppmmmmLLLLooooooookkkkuuuuppppNNNNaaaammmmeeee(3) and
ppppmmmmnnnnssss(4).
PPPPaaaaggggeeee 4444